import { _decorator, Component, instantiate, Node, Vec3 } from 'cc';
import { ClearData } from '../../../Data/GlobalData';
import { BaseComponent } from '../../../Manager/UIManager/BaseComponent';
const { ccclass, property } = _decorator;

@ccclass('ClearNode')
/**
 * 消除游戏层
 */
export class ClearNode extends BaseComponent {

    //砖块数组
    private BrickArray: Node[] = [];

    /**
     * 游戏初始化
     */
    protected Init(): void {
        for (let i = 0; i < ClearData.HorNum; i++) {
            for (let j = 0; j < ClearData.VerNum; j++) {
                let brick: Node = instantiate(app.resManager.Prefabs[ClearData.Prefabs.ClearElement]);
                this.node.addChild(brick);
                brick.setPosition(
                    new Vec3(
                        -ClearData.StageWidth / 2 + (i + 0.5) * ClearData.ElementSpace,
                        -ClearData.StageHeight / 2 + (j + 0.5) * ClearData.ElementSpace,
                    )
                )
                this.BrickArray.push(brick)
            }
        }
    }

    protected OnShow(): void {
        
    }

}


